home *** CD-ROM | disk | FTP | other *** search
- Path: due.unit.no!usenet
- From: Knut Magne Risvik <kmr@orakel.unit.no>
- Newsgroups: comp.lang.c++
- Subject: Re: [HLP] Easy Problem w/ Classes!
- Date: Fri, 23 Feb 1996 11:04:28 +0100
- Organization: The Norwegian University of Science and Technology
- Message-ID: <312D912C.102E7392@orakel.unit.no>
- References: <4gfn3v$jp@news.umbc.edu>
- NNTP-Posting-Host: apollo.orakel.unit.no
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; Linux 1.3.66 i586)
-
- Sunil wrote:
- >
- > Hello all
- > Heres a little problem that I need help with.
- >
- > // Point.h contains
- > Class Point {
- > private: int x;
- > int y;
- >
- > public: Point();
- > }
- >
- > // LineSeg.h contains
- > class LineSeg{
- > private:
- > Point end;
- > Point start;
- > public:
- > LineSeg();
- > }
- >
- > // LineSeg.C contains
- > LineSeg::LineSeg()
- > {
- > Point.end.x=0; // Are these valid?
- > Point.end.y=0; // What do I need to add/del here?
- > Point.start.x=0;
- > Point.start.y=0;
- > }
- >
-
- The operations in LineSeg::LineSeg is not allowed because x and y in the
- Point class are private. Create a constructor for the Point class
- something like this :
-
- Point::Point () {
- x=y=0;
- }
-
- And add functions in Point to set and get x and y coords
-